import VueRouter from 'vue-router';

const routes = [
    {
        path: '/',
        name: 'login',
        component: () => import('../components/LoginPage')
    },
    {
        path: '/IndexPage',
        name: 'index',
        component: () => import('../components/IndexPage.vue'),
        redirect: '/MainPage',
        children:[
            {
                path: '/HomePage',
                name: 'home',
                meta:{
                    title:'个人'
                },
                component: () => import('../components/HomePage'),
            },
            {
                path: '/MainPage',
                name: 'main',
                meta:{
                    title:'首页'
                },
                component: () => import('../components/MainPage'),
            },
            {
                path: '/AdminPage',
                name: 'admin',
                meta:{
                    title:'管理员'
                },
                component: () => import('../components/admin/AdminManage.vue'),
            },
            {
                path: '/UserPage',
                name: 'user',
                meta:{
                    title:'用户'
                },
                component: () => import('../components/user/UserManage.vue'),
            },
        ]
    }
];

const router = new VueRouter({
    mode: 'history',
    routes
});
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
    return VueRouterPush.call(this, to).catch(err => err)
}
export default router;
